package com.fengwk.deeplearning.core;

import java.io.Serializable;

import org.nd4j.linalg.api.ndarray.INDArray;

/**
 * 运算单元集合
 * 
 * @author fengwk
 *
 */
public interface UnitCompute extends Serializable {
	
	enum Enum {
		
		SIGMOID, TANH, RELU;
		
		private final static UnitCompute RELU_UNIT_COMPUTE = new ReLUUnitCompute();
		
		UnitCompute instance() {
			switch (this) {
			case SIGMOID:
				return new SigmoidUnitCompute();
			case TANH:
				return new TanhUnitCompute();
			case RELU:
				return RELU_UNIT_COMPUTE;
			}
			return null;
		}
		
	}
	
	/**
	 * 激活函数
	 * 
	 * @param Z
	 * @return
	 */
	INDArray activate(INDArray Z);
	
	/**
	 * 激活函数导函数
	 * 
	 * @param Z
	 * @return
	 */
	INDArray dActivate(INDArray Z);
	
}
